import React from "react"
import {Button} from 'antd'
import {rootPath, defaultAvatar} from "./init"


export const env = process.env.NODE_ENV
export const DEV = "development"
export const PROD = "production"

//高德地图apiKey
export const gdMapApiKey = '8d64769c7e4f30f99c4d8cb6fc47da63'

//API接口地址
// export const HOST = env === DEV ? "http://localhost:80" : window.myHost
export const HOST = env === DEV ? "http://api.landidz.com" : window.myHost
export const SERVER_HOST = HOST

//校验正则
export const regex_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/

//邮箱正则
export const regex_email = /^.+@[\da-zA-Z]{1,20}\.[a-z]+$/

//身份证号正则
export const regex_id_card = /^(\d{15}|\d{17}[\dxX])$/

export const defaultRouter = `/${rootPath}/profile`


//系统中涉及的文件类型
export const fileType = {
	//博克CAD文件
	BOKE: 'BOKE',
	//不可编辑版型文件
	PLT: 'PLT',
	XLS: 'XLS',
	IMAGE: 'IMAGE'
}

export const pageSetting = {
	showSizeChanger: true,
	showQuickJumper: <Button size={'small'}>跳转</Button>,
	showTotal: (total, range) => (
		<div>
			共 <span className={'line-stress'}>{total}</span> 条,
			当前显示第 <span className={'line-stress'}>{range[0]}</span>-<span className={'line-stress'}>{range[1]}</span> 条
		</div>
	)
}

export const avatarPath = (url) => {
	if (!url) return defaultAvatar
	if (url.startsWith('http://') || url.startsWith('https://')) {
		return url
	}
	return `${HOST}/${url}`
}

//默认的按钮尺寸
export const defaultSize = 'normal'

//排序类型
export const orderType = {
	ascend: 'ASC',
	descend: 'DESC'
}